import GoodsInfo from './GoodsInfo';
import Util from '@/utils/Util';
import Constant from '@/constant/Constants';
import LoggerUtil from '@/utils/LoggerUtil';

export class GoodsCategory {
    public static status_online: number = 1
    public static TYPES:Array<number> = [1,2];
    TYPES_DESC:Array<string> = ['普通','特价'];
    id: number = 0;
    name: string = null;
    image: string = null;
    status: number = null;
    order:number=0;
    type:number=null;
    top: number = 0;
    bottom: number = 0;
    expireTime:Date;
    goodsList = new Array<GoodsInfo>();
    categoryImageList = new Array<string>();
    categoryImgLimit: number = 1;
    selectType:string='请选择';
    constructor(id?: number, name?: string) {
        this.id = id;
        this.name = name;
    }

    setImage() {
        if (!Util.isEmpty(this.categoryImageList)) {
            this.image = this.categoryImageList.join(",").replace(Constant.cdnHost, "");
        } else {
            this.image = null;
        }
    }

    clear() {
        Util.copyWithNull(this, new GoodsCategory())
    }

    getLeftHours(){
        if(Util.isEmpty(this.expireTime)){
            return "";
        }
        let now = new Date();
        let diff =this.expireTime.getTime()-now.getTime();
        var hours=Math.floor(diff/(3600*1000));
        return "距离结单还有"+hours+"小时";
    }


}